package com.cwnu.sw.cys.core.common.constant;

/**
 * @author jisam
 * @version 1.0
 * @contact "jisamchan@outlook.com"
 * @date 26/02/2025
 * @description 管理RedisKey
 */
public class RedisKey {
    private static final String BASE_KEY = "mallchat:chat";

    public static final String USER_TOKEN_STRING ="userToken:uid_%d";


    /**
     * 在线用户列表
     */
    public static final String ONLINE_UID_ZET = "online";

    /**
     * 离线用户列表
     */
    public static final String OFFLINE_UID_ZET = "offline";

    /**
     * 热门房间列表
     */
    public static final String HOT_ROOM_ZET = "hotRoom";

    /**
     * 用户信息
     */
    public static final String USER_INFO_STRING = "userInfo:uid_%d";

    /**
     * 房间详情
     */
    public static final String ROOM_INFO_STRING = "roomInfo:roomId_%d";

    /**
     * 群组详情
     */
    public static final String GROUP_INFO_STRING = "groupInfo:roomId_%d";

    /**
     * 用户的信息更新时间
     */
    public static final String USER_MODIFY_STRING = "userModify:uid_%d";

    /**
     * 用户的信息汇总
     */
    public static final String USER_SUMMARY_STRING = "userSummary:uid_%d";

    /**
     * 用户GPT聊天次数
     */
    public static final String USER_CHAT_NUM = "useChatGPTNum:uid_%d";

    public static final String USER_CHAT_CONTEXT = "useChatGPTContext:uid_%d_roomId_%d";

    /**
     * 保存Open id
     */
    public static final String OPEN_ID_STRING = "openid:%s";


    /**
     * 用户上次使用GLM使用时间
     */
    public static final String USER_GLM2_TIME_LAST = "userGLM2UseTime:uid_%d";
    public static String getKey(String key, Object... args) {
/*        // 检查参数类型是否与格式化字符串匹配
        if (args != null) {
            for (int i = 0; i < args.length; i++) {
                if (key.contains("%d") && !(args[i] instanceof Integer)) {
                    throw new IllegalArgumentException("Format specifier '%d' requires an Integer argument, but got " + args[i].getClass().getSimpleName());
                }
                if (key.contains("%s") && !(args[i] instanceof String)) {
                    throw new IllegalArgumentException("Format specifier '%s' requires a String argument, but got " + args[i].getClass().getSimpleName());
                }
            }
        }*/
        return BASE_KEY + String.format(key, args);
    }

}
